package com.jhgsys.internal.workflow.service;

import com.jhgsys.internal.common.exception.FebsException;
import com.jhgsys.internal.workflow.entity.WorkflowApply;
import com.jhgsys.internal.workflow.entity.WorkflowNode;
import com.jhgsys.internal.common.entity.QueryRequest;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 流程节点表 Service接口
 *
 * @author fenghaijun
 * @date 2024-07-19 08:55:30
 */
public interface IWorkflowNodeService extends IService<WorkflowNode> {
    /**
     * 查询（分页）
     *
     * @param request      QueryRequest
     * @param workflowNode workflowNode
     * @return IPage<WorkflowNode>
     * @author fenghaijun
     * @date 2024-07-19 08:55:30
     */
    IPage<WorkflowNode> findWorkflowNodes(QueryRequest request, WorkflowNode workflowNode);

    /**
     * 查询（所有）
     *
     * @param workflowNode workflowNode
     * @return List<WorkflowNode>
     * @author fenghaijun
     * @date 2024-07-19 08:55:30
     */
    List<WorkflowNode> findWorkflowNodes(WorkflowNode workflowNode);

    /**
     * 根据条件查询
     *
     * @param workflowNode workflowNode
     * @return WorkflowNode
     * @author fenghaijun
     * @date 2024-07-19 08:55:30
     */
    WorkflowNode findWorkflowNode(WorkflowNode workflowNode);

    /**
     * 根据ID查询
     *
     * @param id
     * @return WorkflowNode
     * @author fenghaijun
     * @date 2024-07-19 08:55:30
     */
    WorkflowNode findWorkflowNodeById(String id);

    /**
     * 新增
     *
     * @param workflowNode workflowNode
     * @author fenghaijun
     * @date 2024-07-19 08:55:30
     */
    void createWorkflowNode(WorkflowNode workflowNode);

    /**
     * 修改
     *
     * @param workflowNode workflowNode
     * @author fenghaijun
     * @date 2024-07-19 08:55:30
     */
    void updateWorkflowNode(WorkflowNode workflowNode);

    /**
     * 逻辑删除
     *
     * @param workflowNode    workflowNode
     * @param workflowNodeIds workflowNodeIds
     * @author fenghaijun
     * @date 2024-07-19 08:55:30
     */
    void deleteWorkflowNode(WorkflowNode workflowNode, String workflowNodeIds);

    /**
     * 物理删除
     *
     * @param workflowNodeIds workflowNodeIds
     * @author fenghaijun
     * @date 2024-07-19 08:55:30
     */
    void physicallyDeleteWorkflowNode(String workflowNodeIds);


    /**
     * 流程自定义实现类
     *
     * @param classType classType 1: 自定义审核权限实现 2:自定义节点按钮执行事件实现
     *                  #return String[]
     * @author fenghaijun
     * @date 2024-07-15 17:34:52
     */
    String[] queryWorkflowCustomBean(String classType);

    /**
     * 获取流程开始节点
     *
     * @param workflowId
     * @param workflowId
     * @return
     */
    WorkflowNode getStartNode(String workflowId);

    /**
     * 根据当前节点获取下一节点
     *
     * @param currentNode       当前节点
     * @param customizeBtnId        当前节点操作的按钮Id
     * @param workflowApply     业务申请
     * @param isSaveWorkflowLog 是否保存流程日志
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    WorkflowNode getNextNode(WorkflowNode currentNode, String customizeBtnId, WorkflowApply workflowApply, boolean isSaveWorkflowLog) throws FebsException;

    List<Map<String, String>> queryWorkflowTableColums(String name);

    List<Map<String, String>> selectTable();
}
